﻿using System;
using System.Collections.Generic;
using System.Text;

namespace BCGPSCommon
{
    public class DateTimeToChineseStr
    {

        #region 时间长度转中文
        /// <summary>
        /// 时间长度转中文
        /// </summary>
        /// <param name="totalSeconds"></param>
        /// <returns></returns>
        public static string GetTimeStr(long totalSeconds)
        {
            if (totalSeconds > 0)
            {
                long days = totalSeconds / 86400;
                long hours = (totalSeconds % 86400) / 3600;
                long minutes = (totalSeconds % 86400) % 3600 / 60;
                long seconds = (totalSeconds % 86400) % 3600 % 60;

                if (days > 0)
                    return $"{days}天{hours}小时{minutes}分{seconds}秒";
                if (hours > 0)
                    return $"{hours}小时{minutes}分{seconds}秒";
                if (minutes > 0)
                    return $"{minutes}分{seconds}秒";
                if (seconds > 0)
                    return $"{seconds}秒";
                return "0秒";
            }
            else
                return "0秒";
        }

        #endregion

    }
}
